﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace ObservableCollectionProject
{
    public class AgeValidationRule : ValidationRule
    {
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            double ages = 0;
            if(double.TryParse(value.ToString(),out ages))
            {
                if (ages >= 1 && ages <= 110)
                {
                    return new ValidationResult(true, null);
                }
            }
            return new ValidationResult(false, "请输入1到110之间的数字！");
        }
    }
}
